<%@ page language="java" contentType="text/html; charset=UTF-8"%>
<%@include file="/pageRc/common/common.jsp"%>

<!DOCTYPE html>
<html lang="en" style="overflow-x: hidden">
<head>
<meta charset="UTF-8">
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<meta name="viewport"
	content="initial-scale=1.0,maximum-scale=1.0,user-scalable=no">
<meta name="format-detection" content="telephone=no">
<meta name="apple-mobile-web-app-capable" content="yes">
<meta name="mobile-web-app-capable" content="yes">
<meta name="msapplication-tap-highlight" content="no">

<link rel="stylesheet" href="<%=commonPath%>/pageRc/layui/css/layui.css"
	media="all">
<script type="text/javascript"
	src="<%=commonPath%>/pageRc/js/jquery-1.9.1.min.js"></script>
<script type="text/javascript"
	src="<%=commonPath%>/pageRc/common/utils.js"></script>
<script type="text/javascript"
	src="<%=commonPath%>/pageRc/common/msgTool.js"></script>
<script type="text/javascript"
	src="<%=commonPath%>/pageRc/layui/layui.js"></script>

<title>项目奖励表</title>

<script>
	$(function(){

 	})
	//注意：选项卡 依赖 element 模块，否则无法进行工能性操作
	layui.use('element', function() {
		var element = layui.element();
		//…
	});
</script>
<jsp:include page="publicMethod.jsp" />
</head>
<body class="layui-main" style="width: 100%;">
<blockquote class="layui-elem-quote">项目奖金表</blockquote>
	<div id="createMsgForm" name="createMsgForm" class="layui-form">
             <input id="proGroupNo"  name="proGroupNo"  value="${proGroupNo}"  type="hidden">
             <input id="state"  name="state"  value="${state}"  type="hidden">
             <input id="positionType"  name="positionType"  value="${positionType}"  type="hidden">
            <form id="createMsgForm" name="createMsgForm" class="layui-form"
				action="">
	        <div class="layui-form-item">
				<div class="layui-inline">
					<div class="layui-inline">
					</div>
					<div class="layui-inline">
						报工日期：
					</div>
					<div class="layui-inline">
						<input class="layui-input" style="width: 210" id="bgnWorkDate"
							value="" 
							onclick="layui.laydate({elem: this, istime: true, format: 'YYYYMMDD'})"
							placeholder="起始">
					</div>
					<div class="layui-inline">
						至
					</div>
					<div class="layui-inline">
						<input class="layui-input" style="width: 210" id="endWorkDate"
							value="" 
							onclick="layui.laydate({elem: this, istime: true, format: 'YYYYMMDD'})"
							placeholder="截止">
					</div>
					<div class="layui-inline">
						<button class="layui-btn" type="button" data-method="doSearchSum" id="doSearchSum"><i class="layui-icon" style="font-size: 25px; color: white;">&#xe615;</i></button>
					</div>
					<div class="layui-inline">
						<div class="layui-btn-group">
				              <button  class="layui-btn" type="button" id="TongGuo">通过  <i class="layui-icon" style="font-size: 25px; color: white;">&#xe616;</i></button>
				              <button  class="layui-btn" type="button" id="BoHui">驳回  <i class="layui-icon" style="font-size: 25px; color: white;">&#x1007;</i></button>
						</div>
					</div>
					<c:if test="${positionType == '101'}">
						<div class="layui-inline">
				             <button class="layui-btn" type="button" data-method="doOut">项目毛利表 <i class="layui-icon" style="font-size: 25px; color: white;">&#xe601;</i></button>
							<input id="excelFile" type="file" name="excelFile" lay-type="file"  " class="layui-upload-file" >
						</div>
					</c:if>
					<div class="layui-inline">
		              <button class="layui-btn" type="button" data-method="doExcel">项目奖金表 <i class="layui-icon" style="font-size: 25px; color: white;">&#xe601;</i></button>
					</div>
				</div>
			</div>
		</form>
		<div class="layui-tab">
			<ul class="layui-tab-title">
				<li class="layui-this">项目毛利表</li>
				<li class="">评估表</li>
				<li class="">项目奖励表</li>
				<!-- <li class="layui-this" data-method="doSearchSum"
						id="doSearchSum">项目毛利表</li>
			     <li class="" data-method="doSearchSum1"
						id="doSearchSum1">评估表</li>
				<li class="" data-method="doSearchSum2"
						id="doSearchSum2">项目奖励表</li> -->
			</ul>
			<div class="layui-tab-content">
			<div class="layui-tab-item layui-show">
				<div class="layui-form-item" id="dateDiv3">
					<div class="layui-inline">
						<table class="layui-table" lay-even="" lay-skin="line"
							style="text-align: center; width: 100%;">
							<colgroup align="center">
								<col width="2%">
								<col width="10%">
								<col width="10%">
								<col width="10%">
								<col width="10%">
								<col width="10%">
								<col width="10%">
								<col width="5%">
								<col width="5%">
								<col width="5%">
								<col width="5%">
								<col width="5%">
								<col width="5%">
								<col width="5%">
								<!-- <col width="5%">
								<col width="5%">
								<col width="5%">
								<col width="5%"> -->
								<col width="5%">
								<col width="5%">
								<col width="5%">
							</colgroup>
							<thead>
								<tr>
									<th style="text-align: center;"><input
									type="checkbox" id="all" lay-ignore/></th>
									<th style="text-align: center;">团队名称</th>
									<th style="text-align: center;">项目组</th>
									<th style="text-align: center;">合同号</th>
									<th style="text-align: center;">产品编号/需求编号</th>
									<th style="text-align: center;">需求名称</th>
									<th style="text-align: center;">项目金额(元)</th>
									<th style="text-align: center;">系统核定金额(元)</th>
									<th style="text-align: center;">回款金额(元)</th>
									<th style="text-align: center;">税金(元)</th>
									<th style="text-align: center;">人力成本</th>
									<th style="text-align: center;">项目费用(元)</th>
									<th style="text-align: center;">项目毛利</th>
									<!-- <th style="text-align: center;">团队总收入</th>
									<th style="text-align: center;">团队总人数</th>
									<th style="text-align: center;">总人均产值</th>
									<th style="text-align: center;">总人力成本</th> -->
									<th style="text-align: center;">状态</th>
									<th style="text-align: center;">人力部审核状态</th>
									<th style="text-align: center;">财务部审核状态</th>
								</tr>
							</thead>
							<tbody id="detailDiv1">

							</tbody>
							<script id="tplSrc1" type="text/html">
							 {{#  layui.each(d.mlList, function(index, x){}}
							     <tr align="center">
								   <td>
                             	      <input type="checkbox" value="{{x.rouid}}" lay-ignore />
                             	   </td>
								   <td>{{x.proGroupName==undefined?'':x.proGroupName}}</td>
								   <td>{{x.proTeamName==undefined?'':x.proTeamName}}</td>
								   <td>{{x.contractId==undefined?'':x.contractId}}</td>
								   <td>{{x.contract_no==undefined?'':x.contract_no}}/<a href="javascript:void(0)" onclick="MxByNeedId('{{x.needId}}','{{x.xmje}}','{{x.xthdje}}','{{x.sj}}')"><u>{{x.needNo==undefined?'':x.needNo}}</u></a></td>   
								   <td>{{x.needName==undefined?'':x.needName}}</td>
								   <td>{{x.xmje==undefined?'':x.xmje}}</td>	
								   <td>{{x.xthdje==undefined?'':x.xthdje}}</td>	
                                   <td>{{x.paybackAmount==undefined?'':x.paybackAmount}}</td> 
								   <td>{{x.sj==undefined?'':x.sj}}</td>	
								   <td>{{x.xmcb==undefined?'':x.xmcb}}</td>
								   <td>{{x.projectFee==undefined?'':x.projectFee}}</td>
								   <td>{{x.xmml==undefined?'':x.xmml}}</td>
								  <!--  <td></td>
								   <td></td>
								   <td></td>	
                                   <td></td> -->
                                   <td>{{x.state==undefined?'':x.state=='00'?'待审核':x.state=='01'?'通过审核':x.state=='02'?'驳回':x.state}}</td>
                                   <td>{{x.rl_state==undefined?'':x.rl_state=='00'?'待审核':x.rl_state=='01'?'通过审核':x.rl_state=='02'?'驳回':x.rl_state}}</td>
                                   <td>{{x.cw_state==undefined?'':x.cw_state=='00'?'待审核':x.cw_state=='01'?'通过审核':x.cw_state=='02'?'驳回':x.cw_state}}</td>
								 </tr>
							{{#  }); }}
					   		</script>
						</table>
					</div>
				</div>
			</div>
			<div class="layui-tab-item">
				<div class="layui-form-item" id="dateDiv2">
					<div class="layui-inline">
						<table class="layui-table" lay-even="" lay-skin="line"
							style="text-align: center; width: 100%;">
							<colgroup align="center">
								<col width="10%">
								<col width="10%">
								<col width="10%">
								<col width="10%">
								<col width="5%">
								<col width="5%">
								<col width="5%">
								<col width="5%">
								<col width="5%">
								<col width="5%">
								<col width="5%">
								<col width="5%">
								<col width="5%">
								<col width="5%">
								<col width="5%">
								<col width="5%">
							</colgroup>
							<thead>
								<tr>
									<th style="text-align: center;">团队名称</th>
									<th style="text-align: center;">项目组</th>
									<th style="text-align: center;">需求编号</th>
									<th style="text-align: center;">需求名称</th>
									<th style="text-align: center;">回款金额(元)</th>
									<th style="text-align: center;">需求消耗人月</th>
									<th style="text-align: center;">人均产值</th>
									<th style="text-align: center;">得分</th>
									<th style="text-align: center;">人员结构比例</th>
									<th style="text-align: center;">得分</th>
									<th style="text-align: center;">甲方评分结果</th>
									<th style="text-align: center;">得分</th>
									<th style="text-align: center;">综合得分</th>
									<th style="text-align: center;">状态</th>
									<th style="text-align: center;">人力部审核状态</th>
									<th style="text-align: center;">财务部审核状态</th>
								</tr>
							</thead>
							<tbody id="detailDiv2">

							</tbody>
							<script id="tplSrc2" type="text/html">
							 {{#  layui.each(d.pgList, function(index, x){}}
							     <tr align="center">
								   <td>{{x.proGroupName==undefined?'':x.proGroupName}}</td>
								   <td>{{x.proTeamName==undefined?'':x.proTeamName}}</td>
								   <td>{{x.needNo==undefined?'':x.needNo}}</td>
								   <td>{{x.needName==undefined?'':x.needName}}</td>
									<td>{{x.paybackAmount==undefined?'':x.paybackAmount}}</td>
									<td>{{x.needUseTime==undefined?'':x.needUseTime}}</td>
									<td>{{x.rydc==undefined?'':x.rydc}}</td>
									<td>{{x.dcfz==undefined?'':x.dcfz}}</td>
									<td>{{x.needUserBl==undefined?'':x.needUserBl}}</td>
									<td>{{x.needuserscore==undefined?'':x.needuserscore}}</td>
									<td>{{x.jiaresult==undefined?'':x.jiaresult}}</td>
									<td>{{x.grade==undefined?'':x.grade}}</td>
									<td>{{x.total==undefined?'':x.total}}</td>
                                   <td>{{x.state==undefined?'':x.state=='00'?'待审核':x.state=='01'?'通过审核':x.state=='02'?'驳回':x.state}}</td>
                                   <td>{{x.rl_state==undefined?'':x.rl_state=='00'?'待审核':x.rl_state=='01'?'通过审核':x.rl_state=='02'?'驳回':x.rl_state}}</td>
                                   <td>{{x.cw_state==undefined?'':x.cw_state=='00'?'待审核':x.cw_state=='01'?'通过审核':x.cw_state=='02'?'驳回':x.cw_state}}</td>
								 </tr>
							{{#  }); }}
					   		</script>
						</table>
					</div>
				</div>
			</div>
			<div class="layui-tab-item">
				<div class="layui-form-item" id="dateDiv3">
					<div class="layui-inline">
						<table class="layui-table" lay-even="" lay-skin="line"
							style="text-align: center; width: 100%;">
							<colgroup align="center">
								<col width="10%">
								<col width="10%">
								<col width="10%">
								<col width="10%">
								<col width="10%">
								<col width="10%">
								<col width="10%">
								<col width="10%">
								<col width="8%">	
								<col width="6%">
								<col width="6%">
							</colgroup>
							<thead>
								<tr>
									<th style="text-align: center;">团队名称</th>
									<th style="text-align: center;">项目组</th>
									<th style="text-align: center;">需求编号</th>
									<th style="text-align: center;">需求名称</th>
									<th style="text-align: center;">项目毛利</th>
									<th style="text-align: center;">综合得分</th>
									<th style="text-align: center;">对应奖金等级</th>
									<th style="text-align: center;">奖金金额</th>
									<th style="text-align: center;">状态</th>
									<th style="text-align: center;">人力部审核状态</th>
									<th style="text-align: center;">财务部审核状态</th>
								</tr>
							</thead>
							<tbody id="detailDiv3">

							</tbody>
							<script id="tplSrc3" type="text/html">
							 {{#  layui.each(d.jlList, function(index, x){}}
							     <tr align="center">
								   <td>{{x.proGroupName==undefined?'':x.proGroupName}}</td>
								   <td>{{x.proTeamName==undefined?'':x.proTeamName}}</td>
								   <td>{{x.needNo==undefined?'':x.needNo}}</td>
								   <td>{{x.needName==undefined?'':x.needName}}</td>
									<td>{{x.xmml==undefined?'':x.xmml}}</td>
									<td>{{x.total==undefined?'':x.total}}</td>
									<td>{{x.jjlv==undefined?'':x.jjlv}}</td>
									<td>{{x.jjmoney==undefined?'':x.jjmoney}}</td>
                                   <td>{{x.state==undefined?'':x.state=='00'?'待审核':x.state=='01'?'通过审核':x.state=='02'?'驳回':x.state}}</td>
                                   <td>{{x.rl_state==undefined?'':x.rl_state=='00'?'待审核':x.rl_state=='01'?'通过审核':x.rl_state=='02'?'驳回':x.rl_state}}</td>
                                   <td>{{x.cw_state==undefined?'':x.cw_state=='00'?'待审核':x.cw_state=='01'?'通过审核':x.cw_state=='02'?'驳回':x.cw_state}}</td>
								 </tr>
							{{#  }); }}
					   		</script>
						</table>
					</div>
				</div>
			</div>
		</div>
		</div>
	</div>
	</div>
</body>
<script type="text/javascript">
var path="<%=commonPath%>";
	var msg = new msgTool();
	layui.use(
	[ 'form', 'layer', 'laytpl', 'laypage', 'laydate','upload' ],
	function() {
	var $ = layui.jquery, 
	layer = layui.layer; //独立版的layer无需执行这一句
	var form = layui.form(), 
	layer = layui.layer, 
	laypage = layui.laypage, 
	laytpl = layui.laytpl,
	upload = layui.upload;
	upload({
        url :path+ '/page/main/updNeedInfo.do',
        ext : 'xls|xlsx',
        title : '导入项目毛利表',
        before : function(input) {
            // 返回的参数item，即为当前的input DOM对象
            console.log('文件上传中');
        },
        success : function(res) {
        	if(res.body=="OK"){
        		layer.tips('导入数据成功！', '#excelFile', {
			   		  tips: [2, '#1d953f'],
			   		  area: ['150px', '35px'],
			   		  time: 2000
			   		});
				
			}
        	if(res.body=="FALSE1"){
        		layer.tips('Excle表格中有数据为空,请检查！', '#excelFile', {
			   		  tips: [2, '#FF3030'],
			   		  area: ['150px', '50px'],
			   		  time: 3000
			   		});
				
			}
        	if(res.body=="FALSE2"){
        		layer.tips('Excle表格中月份数据格式不正确,请检查！', '#excelFile', {
			   		  tips: [2, '#FF3030'],
			   		  area: ['150px', '50px'],
			   		  time: 3000
			   		});
				
			}
        	if(res.body=="FALSE3"){
        		layer.tips('Excle表格中没有任何数据,请检查！', '#excelFile', {
			   		  tips: [2, '#FF3030'],
			   		  area: ['150px', '50px'],
			   		  time: 3000
			   		});
				
			}
        	if(res.body=="FALSE4"){
        		layer.tips('Excle表格中有重复工号！', '#excelFile', {
			   		  tips: [2, '#FF3030'],
			   		  area: ['150px', '50px'],
			   		  time: 3000
			   		});
				
			}
        	if(res.body=="FALSE5"){
        		layer.tips('Excle表格中数据和现有数据有重复,请检查！', '#excelFile', {
			   		  tips: [2, '#FF3030'],
			   		  area: ['150px', '50px'],
			   		  time: 3000
			   		});
				
			}
        	if(res.body=="FALSE6"){
        		layer.tips('Excle表格和模板格式不匹配,请检查！', '#excelFile', {
			   		  tips: [2, '#FF3030'],
			   		  area: ['150px', '50px'],
			   		  time: 3000
			   		});
				
			}
        }
    });
	
	var active = {
		doExcel : function() {
			var dataObj = {
					"proGroupNo" : $("#proGroupNo").val(),
					"state" : $("#state").val(),
					"bgnWorkDate" : $("#bgnWorkDate").val(),
					"endWorkDate" : $("#endWorkDate").val()
			}
			msg.sendMsg("/page/main/load.do",
					dataObj, function(data) {
						window.location.href = path
						+ "/downFile/"
						+ data.body.fileName
			});
		},
		doOut : function() {
			var dataObj = {
					"proGroupNo" : $("#proGroupNo").val(),
					"state" : $("#state").val(),
					"bgnWorkDate" : $("#bgnWorkDate").val(),
					"endWorkDate" : $("#endWorkDate").val()
			}
			msg.sendMsg("/page/main/out.do",
					dataObj, function(data) {
						window.location.href = path
						+ "/downFile/"
						+ data.body.fileName
			});
		},
		doSearchSum : function() { //搜索
			var getTpl1 = tplSrc1.innerHTML;
			var getTpl2 = tplSrc2.innerHTML;
			var getTpl3 = tplSrc3.innerHTML;
			var bgnWorkDate = $("#bgnWorkDate").val();
			var endWorkDate = $("#endWorkDate").val();
			var dataObj = {
				"proGroupNo" : $("#proGroupNo").val(),
				"state":$("#state").val(),
				"bgnWorkDate":bgnWorkDate,
				"endWorkDate":endWorkDate
			}
			if(bgnWorkDate != null && endWorkDate != null && bgnWorkDate != "" && endWorkDate != ""){
				if(endWorkDate<bgnWorkDate){
					layer.alert("起始日期不可大于截止日期!");
					return;
				}
			}
			if(bgnWorkDate == null || bgnWorkDate == "" ){
				layer.alert("起始日期不可为空!");
				return;
			}
			if(endWorkDate == null || endWorkDate == ""){
				layer.alert("截止日期不可为空!");
				return;
			}
			msg.sendMsg("/page/need/doJiangjinChaKan.do",dataObj,function(data) {
				laytpl(getTpl1).render(data.body,
					function(html) {
						detailDiv1.innerHTML = html;
					});
				laytpl(getTpl2).render(data.body,
					function(html) {
						detailDiv2.innerHTML = html;
					});
				laytpl(getTpl3).render(data.body,
					function(html) {
						detailDiv3.innerHTML = html;
					});
				form.render('checkbox');
			});
		}
	}
	$('.layui-btn').on('click',function() {
		var othis = $(this), method = othis.data('method');
		active[method] ? active[method].call(this,othis) : '';
	});
});
	
	function MxByNeedId(needId,xmje,xthdje,sj) {
		layer.open({
			type : 2,
			title : "详细信息",
			area : [ '95%', '95%' ],
			scrollbar : false,
			content : '<%=commonPath%>/page/main/' + needId+ '/'+xmje+'/'+xthdje+'/'+sj+'/MxByNeedId.do',
			success : function(layero, index) {
			},
			end : function() {
			}
		});
	}
	
	  layui.use([ 'jquery' ], function() {
			var $ = jQuery;
			$("#all").click(function() {
				$(".che").prop("checked", $(this).prop("checked"));
			})
			$("#BoHui").click(function() {
				var arr = new Array();
				$(".che:checked").each(function(i) {
					arr[i] = $(this).val();
				})
				if(arr.length <=0){
					layer.alert("没有选择任何申请！");
					return false;
				}else{
					layer.confirm("你确定要驳回选中的申请项目奖金信息吗？",{icon:3,title:"提示"},function(index){
						var index=layer.load();
						var checkedRouid = arr.join(",");
						 msg.sendMsg("/page/need/BoHui.do?rouidList="+checkedRouid, '', function (data) {
				                layer.alert("驳回成功！");
				                location.reload();
				            });
						 layer.close(index);
					});
				}
			})
			$("#TongGuo").click(function() {
				var arr = new Array();
				$(".che:checked").each(function(i) {
					arr[i] = $(this).val();
				})
				if(arr.length <=0){
					layer.alert("没有选择任何申请！");
					return false;
				}else{
					layer.confirm("你确定要通过选中的申请项目奖金信息吗？",{icon:3,title:"提示"},function(index){
						var index=layer.load();
						var checkedRouid = arr.join(",");
						 msg.sendMsg("/page/need/TongGuo.do?rouidList="+checkedRouid, '', function (data) {
				                layer.alert("通过成功！");
				                location.reload();
				            });
						 layer.close(index);
					});
				}
			})
		})
	
</script>

</html>
